package org.changchen.fgt.controller;

import java.util.List;

import org.changchen.fgt.dto.LiveChannelDto;
import org.changchen.fgt.dto.LiveSourceErrorUdpateDto;
import org.changchen.fgt.service.LiveChannelService;
import org.changchen.fgt.service.LiveEpgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping(value = "/live")
public class LiveChannelController {

	
	@Autowired
	private LiveChannelService liveChannelService;
	@Autowired
	private LiveEpgService liveEpgService;
	
	
	@GetMapping(value = {""})
	public ModelAndView live() {
		ModelAndView model = new ModelAndView("live");
		return model;
	}
	
	
	@GetMapping(value = "/channel")
	@ResponseBody
	public List<LiveChannelDto> liveChannel() {
		return liveChannelService.channelList();
	}
	
	
	@PostMapping(value = "/error/update")
	@ResponseBody
	public boolean liveSourceErrorUpdate(@RequestBody LiveSourceErrorUdpateDto updateDto) {
		return liveChannelService.sourceErrorUpdate(updateDto);
	}
	
	
	@GetMapping(value = "/epg")
	@ResponseBody
	public List<LiveEpgDto> liveEpg(String channel){
		return liveEpgService.getEpgList(channel);
	}
	

	
	
}
